package pri.damai.xiaowu.usercenter.api.rpc;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.bind.annotation.*;
import pri.damai.xiaowu.common.core.util.ExceptionUtil;
import pri.damai.xiaowu.common.core.vo.ResultVO;
import pri.damai.xiaowu.common.log.anno.XiaoWuLog;
import pri.damai.xiaowu.usercenter.common.dto.LoginDTO;
import pri.damai.xiaowu.usercenter.common.dto.UserDTO;

import javax.annotation.Resource;

/**
 *
 * @Desc
 * @Author DaMai
 * @Date 2022/3/7 9:27
 * 但行好事，莫问前程。
 */
@XiaoWuLog
@RestController
@RequestMapping("/user1")
public class UserCenterFeignClient{

    @Resource
    BCryptPasswordEncoder bCryptPasswordEncoder;

    @PostMapping("/getUserFeign")
    public ResultVO<UserDTO> getUser(@RequestBody LoginDTO loginDTO) {
        UserDTO userDTO = new UserDTO();
        userDTO.setUserId(1L)
                .setGender(1)
                .setPhone("15638577279")
                .setAvatarUrl("");

        ExceptionUtil.isNull(loginDTO.getLoginType(),"登录方式不可为空。");

        return ResultVO.success(userDTO);
    }

    @PostMapping("/password")
    public ResultVO<Void> password(String password) {
        String encode = bCryptPasswordEncoder.encode(password);
        System.out.println(encode);
        return ResultVO.success();
    }
}
